﻿using Beetle;
using Smark.Core;
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

internal class Class_ae
{
    public bool _field_a;
    public string _field_b;
    public string _field_c;
    public int _field_d;
    public DateTime _field_e;
    private static Class_ae _field_f = null;
    private static RSACryptoServiceProvider _field_g = null;
    private static string _field_h;
    private static string _field_i;
    private static Class_ae_a _field_j = new Class_ae_a();
    private static string[] _field_k;
    private static string[] _field_l;
    private static DateTime _field_m = DateTime.Now;
    private static char[] _field_n = new char[] { '\r', '\n' };

    static Class_ae()
    {
        _field_g = (RSACryptoServiceProvider) Class_af.c();
    }

    public static Class_ae f()
    {
        lock (typeof(Class_ae))
        {
            if (_field_f == null)
            {
                _field_f = new Class_ae();
                try
                {
                    _field_g.FromXmlString(_field_j.c());
                    using (StreamReader reader = new StreamReader(TcpUtils.g() + _field_j.d()))
                    {
                        g(reader.ReadToEnd());
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        Class_b._field_c = _field_f._field_a;
        return _field_f;
    }

    public static byte[] f(byte[] A_0)
    {
        return _field_g.Decrypt(A_0, false);
    }

    public bool f(int A_0)
    {
        return (this._field_a && (A_0 <= this._field_d));
    }

    internal static string f(string A_0)
    {
        DESCrypto crypto = new DESCrypto();
        DESCrypto.DESInfo info = new DESCrypto.DESInfo {
            IV = Convert.FromBase64String(TcpServer._field_g),
            Key = Convert.FromBase64String(TcpChannel._field_k)
        };
        crypto.KeyInfo = info;
        return crypto.Decrypt(A_0);
    }

    public static bool f(byte[] A_0, byte[] A_1)
    {
        return _field_g.VerifyData(A_0, "MD5", A_1);
    }

    public static bool f(string A_0, string A_1)
    {
        return f(Encoding.UTF8.GetBytes(A_0), Convert.FromBase64String(A_1));
    }

    private static void g()
    {
        _field_f._field_b = _field_l[0];
        _field_f._field_c = _field_l[1];
        _field_f._field_d = int.Parse(_field_l[2]);
    }

    private static void g(string A_0)
    {
        _field_k = A_0.Split(_field_n, StringSplitOptions.RemoveEmptyEntries);
        if (f(_field_k[0], _field_k[1]))
        {
            _field_l = Encoding.UTF8.GetString(Convert.FromBase64String(_field_k[0])).Split(new char[] { ';' });
            g();
            _field_f._field_e = new DateTime(long.Parse(_field_l[3]));
            _field_f._field_a = _field_f._field_e > _field_m;
        }
    }

    public static string h(string A_0)
    {
        return Encoding.UTF8.GetString(f(Convert.FromBase64String(A_0)));
    }

    private class Class_ae_a
    {
        public string a = Class_af.a();
        public string b = Class_af.b();

        public string c()
        {
            return Class_ae.f(this.a);
        }

        public string d()
        {
            return Class_ae.f(this.b);
        }
    }
}

